﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using NETMovie.UI.WebMVC.Models;
using NETMovie.Entities;

namespace NETMovie.UI.WebMVC.Mappers
{
    public class PaymentMapper
    {
        public PaymentModel ReMap(ViewRentalCartModel rentalModel, User user)
        {
            PaymentModel model = new PaymentModel();
            model.TransactionID = rentalModel.TransactionID;
            model.TransactionNo = rentalModel.TransactionNo;
            model.TotalAmount = rentalModel.TotalAmount;
            model.PostalCode = user.PostalCode;
            model.AddressLine1 = user.AddressLine1;
            model.AddressLine2 = user.AddressLine2;
            model.City = user.City;
            model.Country = user.Country.CountryCode;

            return model;
        }

        public Payment Map(PaymentModel model)
        {
            Payment payment = new Payment();
            payment.AddressLine1 = model.AddressLine1;
            payment.AddressLine2 = model.AddressLine2;
            payment.CCExpiryMonth = model.ExpiryMonth;
            payment.CCExpiryYear = model.ExpiryYear;
            payment.City = model.City;
            payment.Country = new Country();
            payment.Country.CountryCode = model.Country;
            payment.CreditCardNo = model.CCNo;
            payment.CreditCardType = Convert.ToInt32(model.CCType);
            payment.PayerFirstName = model.PayerFirstName;
            payment.PayerLastName = model.PayerLastName;
            payment.PostalCode = model.PostalCode;
            payment.TransactionInfo = new Transaction();
            payment.TransactionInfo.TransactionId = model.TransactionID;
            payment.TransactionInfo.TransactionNo = model.TransactionNo;
            payment.TransactionInfo.TotalAmount = model.TotalAmount;

            return payment;
        }
    }
}